home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 026-050 / scopedisk45 / mffcis / parsecislib.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-18  |  3KB  |  136 lines

  1. /* ParseCISLib.rexx */
  2. /* Parse TAPCIS library files. This must be run from CLI as a synchonous MFF
  3. macro.  MFF has problems with many AREXX fuctions in native mode.  MFF
  4. must be running an a CISLIB type database must be open
  5. */
  6.  
  7. /* constants */
  8.  
  9. /* For use with WHAP */
  10. LibPrompt  = 'LIB'
  11.  
  12. /* For use with TAPCIS */
  13. /* LibPrompt  = 'DL' */
  14.  
  15. DefaultDir = 'RAM:'
  16.  
  17. options results
  18.  
  19. /* lock to mff */
  20.  
  21. address mff_server1 lock
  22. if rc~=0 THEN DO
  23.   SAY 'NO LOCK ON MFF!'
  24.   EXIT 10
  25. END
  26. ADDRESS VALUE RESULT
  27.  
  28. /* If you are using a separate database for each ForUm you could elimate
  29. the FORUM field from the database and omit all references to it in this
  30. program */
  31. string_request 'What Library are you cataloging(AMIGAT, etc)?'
  32.  
  33. Forum = result
  34.  
  35. /* we need the  ARP library for this */
  36.  
  37.  
  38. if ~show('L',"rexxarplib.library") then DO
  39.    if ~addlib('rexxarplib.library',0,-30,0) then DO
  40.       say 'support library not available!'
  41.       EXIT 0
  42.    end
  43. end
  44.  
  45.  
  46. /* bring up the cheath file requestor */
  47.  
  48.  
  49. ParseFile = getfile(20, 20,DefaultDir,,"Choose File to parse",)
  50.  
  51.    if length(ParseFile) < 1 then DO
  52.      result =  postmsg(50,50,"No option specified.",)
  53.      result =  postmsg()
  54.    END
  55.  
  56.  
  57.  
  58. IF Open(infile,ParseFile,'READ') THEN 
  59.  
  60. DO WHILE ~EOF(infile)
  61.    str = ReadLn(infile)
  62.  
  63.    PARSE VAR str a b c 
  64.    IF (a = LibPrompt) THEN Lib = strip(b);
  65.    PARSE VAR str '[' usernum ']'
  66.  
  67.    IF ~(usernum = '') THEN DO
  68.       /* okay, we got a file description */
  69.       str = ReadLn(infile)
  70.       PARSE VAR str name '/' type date size DownLoads
  71.       IF length(name) > 10 THEN
  72.           /* file type not specified, probably text */
  73.           PARSE VAR str name date size DownLoads
  74.       /* skip a line */
  75.       DO FOR 2
  76.          str = strip(readln(infile)) 
  77.       END
  78.       /* Get Keywords */
  79.       PARSE VAR str junk Keywords
  80.       Keywords = strip(Keywords)
  81.       DO WHILE ~(str='')
  82.          str = readln(infile)
  83.          str = strip(str)
  84.          keywords = keywords str
  85.       END
  86.  
  87.       descr = strip(readln(infile))
  88.       DO UNTIL (str='')
  89.          str = readln(infile)
  90.          str = strip(str)
  91.          descr = descr || '0A'x || str
  92.       END
  93.  
  94.       /* Change date format to YY.MM.DD so MFF can sort on it */
  95.  
  96.       PARSE VAR date day '-' month '-' year
  97.       SELECT
  98.         WHEN month = 'Jul' THEN mm = 07
  99.         WHEN month = 'Aug' THEN mm = 08
  100.         WHEN month = 'Sep' THEN mm = 09
  101.         WHEN month = 'Oct' THEN mm = 10
  102.         WHEN month = 'Nov' THEN mm = 11
  103.         WHEN month = 'Dec' THEN mm = 12
  104.         WHEN month = 'Jan' THEN mm = 01
  105.         WHEN month = 'Feb' THEN mm = 02
  106.         WHEN month = 'Mar' THEN mm = 03
  107.         WHEN month = 'Apr' THEN mm = 04
  108.         WHEN month = 'May' THEN mm = 05
  109.         WHEN month = 'Jun' THEN mm = 06
  110.         OTHERWISE mM = 0
  111.       END
  112.  
  113.       date = year || '.' || mm || '.' || day
  114.       /* assign values to database record */
  115.       get_blank Rec
  116.       Rec.1.value = name
  117.       Rec.2.value = date
  118.       Rec.3.value = size
  119.       Rec.4.value = usernum
  120.       Rec.5.value = descr
  121.       Rec.6.value = forum
  122.       Rec.7.value = Lib
  123.       Rec.8.value = Keywords
  124.       add Rec
  125.    END
  126.  
  127. END
  128. close(inFile)
  129.  
  130. save_database quietly
  131.  
  132. /* DISCONNECT FROM MFF */
  133. UNLOCK
  134.  
  135. EXIT
  136.